package com.zby.ss.core.util;

import org.apache.commons.lang3.StringUtils;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created By zby on 18:42 2019/2/24
 * 操作map的工具类
 */

public class MapUtil {

    /**
     * Created By zby on 18:45 2019/2/24
     * 判断是否找到这个key值
     */
    public static boolean findKey(Map map, String key) {
        if (null == map && map.size() == 0) {
            return false;
        }
        if (StringUtils.isBlank(key)) {
            throw new RuntimeException("key值不存在key=" + key);
        }
        Set<String> keySet = map.keySet();
        for (Iterator keyIt = keySet.iterator(); keyIt.hasNext(); ) {
            String tmpKey = (String) keyIt.next();
            if (tmpKey.equals(key)) {
                return true;
            }
        }
        return false;
    }
}
